package factory;

import dao.NewsDao;
import dao.imp.NewsDaoMySqlImpl;
import dao.imp.NewsDaoOracleImpl;
import dao.imp.NewsDaoRedisImpl;

public class SimpleDaoFactory {
    /**
     6. * 创建 NewsDao 实例的工厂方法
     7. */
 public static NewsDao getInstance(String key) {
        //return new NewsDaoImpl();
         switch (key) {
             case "mysql":
              return new NewsDaoMySqlImpl();
             case "oracle":
             return new NewsDaoOracleImpl();
             case "redis":
             return new NewsDaoRedisImpl();
             default:
             throw new RuntimeException("无效的数据库类型："+key
              +" ，DAO 获取失败");
              }
       }
}
